package pro.cherish.knowledgedemoasync.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import pro.cherish.knowledgedemoasync.service.ThreadLocalParam;

import java.util.concurrent.ExecutionException;

/**
 * @author 创建人：cherish
 * @version 版本号：V1.0
 * <p>
 * ***************************修订记录************************************
 * 2019-10-27 cherish 创建该类功能。
 * **********************************************************************
 * </p>
 * @ClassName 类名：TestController
 * @Description 功能说明：测试@Async能否拿当前线程的变量及ThreadLocal结合，以及能否拿主程序的IOC中的Bean
 * <p>
 * TODO
 * </p>
 * **********************************************************************
 * @date 创建日期： 2019-10-27 cherish
 */
@RestController
@Slf4j
public class TestController3 {

    @Autowired
    private User user;

    @RequestMapping("/test3")
    public void testAsync(String currentUserName) throws InterruptedException, ExecutionException {
        ThreadLocalParam.threadLocalparam.set(currentUserName);
        user.takePhone_async();
        log.info("主线程结束");
    }
}
